<template>
	<view class="searchbox">
		<view class="search">
			<!-- uni-ui 组件   -->
			<uni-search-bar @confirm="search" v-model="searchValue" @blur="blur" @focus="focus" @input="input"
				@cancel="cancel" @clear="clear" placeholder="搜索">
			</uni-search-bar>
		</view>
		<view class="" v-for="item in resultlist" :key="item.goods_id">
			<!-- navigator 声明式导航   -->
			<navigator url="">
				{{item.goods_name}}
			</navigator>
		</view>
	</view>
</template>

<script>
	import {
		getGoodslist
	} from '../../utils/http.js'
	export default {
		name: "mysearch",
		data() {
			return {
				searchValue: "", //输入框的内容
				resultlist: [],
			};
		},
		methods: {

			search() { // 回车搜索
				getGoodslist({
					query: this.searchValue
				}).then((res => {
					console.log(res);
					this.resultlist = res.data.message.goods
				}))

			},
			blur() { // 失去焦点

			},
			focus() { //获取焦点

			},
			input() { //输入变化触发

			},
			cancel() { // 区销售

			},
			clear() { // 清空

			}
		}
	}
</script>

<style lang="scss">
	.search {
		background-color: #c00;
	}
</style>
